// 定义函数类型
let add: (x: number, y: number) => number;

interface Add1 {
	(x: number, y: number): number
}

type Add2 = (x: number, y: number) => number

function add3(x: number, ...rest: number[]) {
	return x+rest.reduce((pre, cur) => pre + cur, 0);
}

// 混合类型的接口
interface Lib {
	(): void;
	
	version: string;
	
	doSomething(): void;
}

function getLib() {
	// 类型断言
	let lib: Lib = (() => {
	}) as Lib;
	lib.version = "1.0.0";
	lib.doSomething = () => {
	};
	return lib;
}

let lib1 = getLib();
console.log(lib1.version);

interface List {
	id: number;
	name?: string;
	readonly age: number;
	
	[x: string]: string;
	
	//数字签名的类型一定要是 字符串类型签名的子类型
	[y: number]: string;
}

let a = 10;

interface Result {
	data: List[]
}

class Animal {
	//*
	// 作为基类
	// */
	protected constructor() {
		console.log("cc");
	}
	
}
// new Animal()

abstract class Dog {
	abstract xx():()=>void;
	eat(){
		console.log("eat eat");
	}
}

interface C{
	():void;
	test():string;
}

const cc = (()=>{}) as C;
cc.test=()=>{
	return ""
}
